package com.example.streams;

import com.example.lists.User;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author hej
 * @date 2023/5/31 10:11
 */
public class Streamjoining {
    public static void main(String[] args) {
        //取某个字段去重再拼接
        List<User> users = new ArrayList<>();
        users.add(new User(1,1,"张三"));
        users.add(new User(2,2,"李四"));
        users.add(new User(3,3,"张三"));
        users.add(new User(4,4,"王五"));
        users.add(new User(5,5,"张三"));
        String name = users.stream().map(User::getLable).distinct().collect(Collectors.joining(","));
        System.out.println(name);
    }
}
